package cn.com.jsr.translation.termidentifier.identifier;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import cn.com.jsr.translation.termidentifier.Seeker;

public class Translate extends Seeker{
	private static Logger logger = LoggerFactory.getLogger(Translate.class);

	@Override
	public String onmatch(String content, String term, int policy){
		boolean ignoreCase = (Seeker.CASE_INSENSITIVE & policy) == Seeker.CASE_INSENSITIVE;
		boolean mergeBlanks = (Seeker.MERGE_BLANK & policy) == Seeker.MERGE_BLANK;
		
		if(ignoreCase && mergeBlanks)
			return this.dictionary.get(term);
		if(ignoreCase && !mergeBlanks)
			return this.dictionary.get(term);
		if(!ignoreCase && mergeBlanks)
			return this.dictionary.get(content.replaceAll("\\s+", " "));
		if(!ignoreCase && !mergeBlanks)
			return this.dictionary.get(content);
		
		return null;
	}
}
